package net.haiyue.api.entity;
import javax.persistence.*;
import java.util.Date;
import java.util.List;
import java.util.Set;

@Entity
@Table(name = "modules")
public class Module extends BaseEntity {
    @Column
    private String name;
    @Column
    private String status;
    @Column
    private Date create_time;
    @Column
    private String oper;
    @Column
    private String comment;
    @Column
    private Date time_begin;
    @Column
    private Date time_end;
    @Column
    private Integer percent;
    @Column
    private Integer finished_percent;
    @Column
    private Integer pre_duration;

    @ManyToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER,targetEntity = User.class)
    @JoinTable(name = "rmu", inverseJoinColumns = @JoinColumn(name = "uid"), joinColumns = @JoinColumn(name = "mid"))
    private List<User> users;

    @ManyToOne(fetch = FetchType.EAGER)
    @JoinColumn(name = "pid")
    private Project project;

    @Transient
    private Integer[] uids;

    public Integer[] getUids() {
        return uids;
    }

    public void setUids(Integer[] uids) {
        this.uids = uids;
    }

    public Project getProject() {
        return project;
    }

    public void setProject(Project project) {
        this.project = project;
    }

    public List<User> getUsers() {
        return users;
    }

    public void setUsers(List<User> users) {
        this.users = users;
    }
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public Date getCreate_time() {
        return create_time;
    }

    public void setCreate_time(Date create_time) {
        this.create_time = create_time;
    }

    public String getOper() {
        return oper;
    }

    public void setOper(String oper) {
        this.oper = oper;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public Date getTime_begin() {
        return time_begin;
    }

    public void setTime_begin(Date time_begin) {
        this.time_begin = time_begin;
    }

    public Date getTime_end() {
        return time_end;
    }

    public void setTime_end(Date time_end) {
        this.time_end = time_end;
    }

    public Integer getPercent() {
        return percent;
    }

    public void setPercent(Integer percent) {
        this.percent = percent;
    }

    public Integer getFinished_percent() {
        return finished_percent;
    }

    public void setFinished_percent(Integer finished_percent) {
        this.finished_percent = finished_percent;
    }

    public Integer getPre_duration() {
        return pre_duration;
    }

    public void setPre_duration(Integer pre_duration) {
        this.pre_duration = pre_duration;
    }

    public Module() {
    }

    @Override
    public String toString() {
        return "Module{" +
                "name='" + name + '\'' +
                ", status='" + status + '\'' +
                ", create_time=" + create_time +
                ", oper='" + oper + '\'' +
                ", comment='" + comment + '\'' +
                ", time_begin=" + time_begin +
                ", time_end=" + time_end +
                ", percent=" + percent +
                ", finished_percent=" + finished_percent +
                ", pre_duration=" + pre_duration +
                ", users=" + users +
                '}';
    }
}